$(function(){
		/*初始化表格*/
		$('#trainStation').datagrid({
    		url:'backtrainstationjson',
    		collapsible:true,
    		fit:true,
			fitColumns:true,
			toolbar:'#footer',
			pagination:true,
			pageSize:20,
			pageList:[20,50,100,200],
			remoteSort:false,
   			columns:[[
   			 	{field:'ck',checkbox:true},
   			 	{field:'stationID',hidden:'true'},
			{field:'stationName',title:'火车站名称',align:'center',width:'20%'},
				{field:'zoneName',title:'所在区域',align:'center',width:'20%'},
				{field:'memo',title:'备注',align:'center',width:'58%'}
    		]]
		});
			
});

/*搜索*/
function searchTrainStation(){
	
		
	var stationName = $("#searchTrainStationName").val(); 
		
		$("#trainStation").datagrid("load",{
			stationName:stationName
		})
	}
	
/*清空*/
function clearTrainStation(){
        $("#searchTrainStationName").val('');
	
     }


// 修改机场信息
function updateTrainStation() {
	
		var rows = $('#trainStation').datagrid('getSelections');
		var checkNum = rows.length;
		if(checkNum==0){
			$.messager.alert('错误','至少选择一项','error');
		 } else if(checkNum>1){
			$.messager.alert('错误','最多选择一项','error');
		 }else{
			//判断创建人所属公司是否相同  登陆人与创建人公司相同
			var travelOrgID = rows[0].spare1;
			var sessionOrgID=$("#sessionOrgID").val();
			if(parseInt(travelOrgID)==parseInt(sessionOrgID)){
		$.messager.confirm('Confirm', '确定要修改吗?', function(r){
	if (r){
		var iStationID = rows[0].stationID; 
		 	location.href="/mmy/backtoupdatetrainstation?iStationID="+iStationID;
	}
});
			
	
	}else{
		$.messager.alert('错误','无法修改','error');
		
	}
		 }
	
	
	
	
	
}


